package com.gzr.demo01;

/**
 * 静态代理
 */
public class StaticProxy {
    public static void main(String[] args) {
        new WeddingCompany(new You()).HappyMarry();
    }
}

interface Marry{
    void HappyMarry();
}

//真实角色
class You implements Marry {
    @Override
    public void HappyMarry() {
        System.out.println("你要结婚了");
    }
}

//代理角色,代理结婚
class WeddingCompany implements Marry {
    //代理谁 真实角色目标对象

    private Marry target;

    public WeddingCompany(Marry target){
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void after() {
        System.out.println("结婚后数钱");
    }

    private void before() {
        System.out.println("结婚前布置现场");
    }
}
